package com.zjq.smartdevice.service.impl;

import com.zjq.smartdevice.mapper.SysMenuMapper;
import com.zjq.smartdevice.pojo.SysMenu;
import com.zjq.smartdevice.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @User zhangjiaqi
 * @Project project
 * @Package com.zjq.smartdevice.service.impl
 * @Date 2022/3/24 22:43
 */
@Service
@Transactional
public class SysMenuServiceImpl implements SysMenuService {

    private SysMenuMapper sysMenuMapper;

    @Autowired
    public void setSysMenuMapper(SysMenuMapper sysMenuMapper) {
        this.sysMenuMapper = sysMenuMapper;
    }

    @Override
    public List<SysMenu> findAllMenu() {
        return sysMenuMapper.findAllMenu();
    }

    @Override
    public List<SysMenu> findAllLeftMenu() {
        List<SysMenu> allMenu = findAllMenu();
        List<SysMenu> menuList = allMenu.stream().filter(sysMenu -> {
            return sysMenu.getMenuType().equalsIgnoreCase("M")&&!"#".equalsIgnoreCase(sysMenu.getUrl());
        }).collect(Collectors.toList());
        return menuList;
    }


}
